package com.brainhealth.web.controller.customer;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.brainhealth.common.annotation.Log;
import com.brainhealth.common.core.controller.BaseController;
import com.brainhealth.common.core.domain.AjaxResult;
import com.brainhealth.common.enums.BusinessType;
import com.brainhealth.customer.domain.CustomerChat;
import com.brainhealth.customer.service.ICustomerChatService;
import com.brainhealth.common.utils.poi.ExcelUtil;
import com.brainhealth.common.core.page.TableDataInfo;

/**
 * 会员聊天Controller
 * 
 * @author ruoyi
 * @date 2023-05-17
 */
@RestController
@RequestMapping("/customer/customerChat")
public class CustomerChatController extends BaseController
{
    @Autowired
    private ICustomerChatService customerChatService;

    /**
     * 查询会员聊天列表
     */
    @PreAuthorize("@ss.hasPermi('customer:customerChat:list')")
    @GetMapping("/list")
    public TableDataInfo list(CustomerChat customerChat)
    {
        startPage();
        List<CustomerChat> list = customerChatService.selectCustomerChatList(customerChat);
        return getDataTable(list);
    }

    /**
     * 导出会员聊天列表
     */
    @PreAuthorize("@ss.hasPermi('customer:customerChat:export')")
    @Log(title = "会员聊天", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CustomerChat customerChat)
    {
        List<CustomerChat> list = customerChatService.selectCustomerChatList(customerChat);
        ExcelUtil<CustomerChat> util = new ExcelUtil<CustomerChat>(CustomerChat.class);
        util.exportExcel(response, list, "会员聊天数据");
    }

    /**
     * 获取会员聊天详细信息
     */
    @PreAuthorize("@ss.hasPermi('customer:customerChat:query')")
    @GetMapping(value = "/{customerChatId}")
    public AjaxResult getInfo(@PathVariable("customerChatId") Long customerChatId)
    {
        return success(customerChatService.selectCustomerChatByCustomerChatId(customerChatId));
    }

    /**
     * 新增会员聊天
     */
    @PreAuthorize("@ss.hasPermi('customer:customerChat:add')")
    @Log(title = "会员聊天", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CustomerChat customerChat)
    {
        return toAjax(customerChatService.insertCustomerChat(customerChat));
    }

    /**
     * 修改会员聊天
     */
    @PreAuthorize("@ss.hasPermi('customer:customerChat:edit')")
    @Log(title = "会员聊天", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CustomerChat customerChat)
    {
        return toAjax(customerChatService.updateCustomerChat(customerChat));
    }

    /**
     * 删除会员聊天
     */
    @PreAuthorize("@ss.hasPermi('customer:customerChat:remove')")
    @Log(title = "会员聊天", businessType = BusinessType.DELETE)
	@DeleteMapping("/{customerChatIds}")
    public AjaxResult remove(@PathVariable Long[] customerChatIds)
    {
        return toAjax(customerChatService.deleteCustomerChatByCustomerChatIds(customerChatIds));
    }
}
